Skip to content

fix: The font size of the category jump menu does not adjust with the system font size when sorting by category#705

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
electricface:swt/fix-bug335169
Mar 9, 2026
Merged

fix: The font size of the category jump menu does not adjust with the system font size when sorting by category#705
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
electricface:swt/fix-bug335169

Conversation

@electricface
Copy link
Member

@electricface electricface commented Feb 6, 2026

fix: 按分类排序时,分类跳转菜单字体大小不随系统字体大小调整而改变问题

Log: 修复按分类排序时,分类跳转菜单字体大小不随系统字体大小调整而改变问题
Influence: 启动器分类跳转菜单文字大小
PMS: BUG-335169

@sourcery-ai
Copy link

sourcery-ai bot commented Feb 6, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Binds various launcher menus and the search box to the shared DTK font manager so their text size updates immediately when the global font size changes.

Sequence diagram for launcher font size change propagation

sequenceDiagram
    actor User
    participant SettingsApp
    participant DTK_fontManager
    participant AppItemMenus
    participant CategoryMenus
    participant SearchBox

    User->>SettingsApp: changeFontSize(newSize)
    SettingsApp->>DTK_fontManager: setFontSize(newSize)
    DTK_fontManager-->>DTK_fontManager: update_t6_font
    DTK_fontManager-->>AppItemMenus: notify_font_changed(t6)
    DTK_fontManager-->>CategoryMenus: notify_font_changed(t6)
    DTK_fontManager-->>SearchBox: notify_font_changed(t6)

    AppItemMenus-->>AppItemMenus: font bound to DTK_fontManager.t6
    CategoryMenus-->>CategoryMenus: font bound to DTK_fontManager.t6
    SearchBox-->>SearchBox: font bound to DTK_fontManager.t6

    AppItemMenus-->>User: menu text size updated
    CategoryMenus-->>User: sort and category menu text size updated
    SearchBox-->>User: search text size updated immediately
Loading

Flow diagram for DTK font manager bindings in launcher components

flowchart LR
    DTK_fontManager_t6[DTK_fontManager.t6]

    DTK_fontManager_t6 --> AppItemMenu_font
    DTK_fontManager_t6 --> DummyAppItemMenu_font
    DTK_fontManager_t6 --> CategoryMenu_font
    DTK_fontManager_t6 --> CategoryMenu_label_font
    DTK_fontManager_t6 --> SearchBox_font

    AppItemMenu_font[AppItemMenu D.Menu font]
    DummyAppItemMenu_font[DummyAppItemMenu D.Menu font]
    CategoryMenu_font[SideBar categorizedMenu font]
    CategoryMenu_label_font[AppListView category label font]
    SearchBox_font[BottomBar searchEdit font]
Loading

File-Level Changes

Change Details Files
Bind category jump menu and its label text to the shared DTK font so they follow global font size changes.
  • Assign DTK.fontManager.t6 to the category menu popup font property.
  • Bind the internal Text element’s font to the menu’s font to keep label styling consistent.
qml/windowed/AppListView.qml
Bind all app context menus (including dummy menu) to the shared DTK font manager.
  • Set the font of the dummy app item context menu’s D.Menu to DTK.fontManager.t6 so its items resize with the global font.
  • Set the font of the main app item context menu’s D.Menu to DTK.fontManager.t6 to ensure consistent font size updates.
qml/DummyAppItemMenu.qml
qml/AppItemMenu.qml
Bind the search box text font to the shared DTK font manager so it scales with the global font size.
  • Set the search edit field font to DTK.fontManager.t6 so its text reacts immediately to font size changes.
qml/windowed/BottomBar.qml
Bind sidebar sort mode menu to the shared DTK font manager.
  • Set the sidebar categorizedMenu font to D.DTK.fontManager.t6 so its menu items follow global font size.
qml/windowed/SideBar.qml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • There’s an inconsistency in how the font manager is referenced (DTK.fontManager.t6 vs D.DTK.fontManager.t6 in SideBar.qml); consider aligning on a single import/alias pattern to avoid confusion and future mistakes.
  • You’re now repeating font: DTK.fontManager.t6 across several components; consider introducing a shared style or wrapper component for menus/search inputs to centralize this binding and make future font changes easier.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- There’s an inconsistency in how the font manager is referenced (`DTK.fontManager.t6` vs `D.DTK.fontManager.t6` in `SideBar.qml`); consider aligning on a single import/alias pattern to avoid confusion and future mistakes.
- You’re now repeating `font: DTK.fontManager.t6` across several components; consider introducing a shared style or wrapper component for menus/search inputs to centralize this binding and make future font changes easier.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • In SideBar.qml you’re using D.DTK.fontManager.t6 while the other files use DTK.fontManager.t6; consider aligning the namespace usage to avoid subtle runtime binding issues.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In SideBar.qml you’re using `D.DTK.fontManager.t6` while the other files use `DTK.fontManager.t6`; consider aligning the namespace usage to avoid subtle runtime binding issues.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Member

@BLumia BLumia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是不是应该 dtkdeclarative 改更合理,按理说所有的 Menu/MenuItem 都应该有相同的行为?

cc @18202781743

@BLumia BLumia requested a review from 18202781743 February 6, 2026 05:49
id: categorizedCom
D.Menu {
id: categorizedMenu
font: D.DTK.fontManager.t6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉是启动器这个场景出了问题,像启动器的搜索框弹出的右键菜单也是错误的,但在控制中心就是对的,
启动器的窗口是个PopupWindow,像是没有继承Window的font变化,

@deepin-bot
Copy link

deepin-bot bot commented Feb 27, 2026

TAG Bot

New tag: 2.0.27
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #714

@deepin-bot
Copy link

deepin-bot bot commented Mar 5, 2026

TAG Bot

New tag: 2.0.28
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #720

@deepin-bot
Copy link

deepin-bot bot commented Mar 6, 2026

TAG Bot

New tag: 2.0.29
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #723

@deepin-bot
Copy link

deepin-bot bot commented Mar 6, 2026

TAG Bot

New tag: 2.0.30
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #724

@electricface electricface changed the title fix: Application context menu font not changing immediately with font size adjustment fix: The font size of the category jump menu does not adjust with the system font size when sorting by category Mar 8, 2026
with the system font size when sorting by category

---

fix: 按分类排序时,分类跳转菜单字体大小不随系统字体大小调整而改变问题

Log: 修复按分类排序时,分类跳转菜单字体大小不随系统字体大小调整而改变问题
Influence: 启动器分类跳转菜单文字大小
PMS: BUG-335169
@deepin-ci-robot
Copy link

deepin pr auto review

这段代码的修改主要涉及 QML 中 UI 组件的字体样式设置。以下是对这段 git diff 的审查意见,涵盖语法逻辑、代码质量、性能和安全性四个方面:

1. 语法逻辑

  • 分析:代码逻辑正确。在 MenuItem 中设置了 font 属性为 DTK.fontManager.t6,并在其子元素(推测是 contentItem 或自定义的 Label)中通过 font: menuItem.font 继承了该字体设置。这符合 QML 的属性绑定和继承机制。
  • 结论:逻辑无误,能够实现字体样式的统一应用。

2. 代码质量

  • 可维护性
    • 使用 DTK.fontManager.t6 是一种好的实践,因为它使用了 DTK(DDE Toolkit)的统一字体管理,而不是硬编码字体大小(如 pixelSize: 14)。这有助于未来在全局范围内调整字体样式。
  • 一致性
    • 代码显式地将 textColor 设置为 DStyle.Style.menu.itemText,但字体设置却依赖 DTK。建议检查项目中 DStyleDTK 的混用是否符合项目规范,或者是否应该统一使用其中一个库的字体管理接口。
  • 可读性
    • menuItem.font 的引用清晰,表明了属性的来源。

3. 代码性能

  • 绑定开销
    • font: menuItem.font 建立了一个属性绑定。虽然字体属性通常不会频繁变化,但在复杂的列表视图或大量菜单项中,过多的属性绑定会带来轻微的计算开销。
    • 优化建议:如果 menuItem.font 在初始化后完全不会改变,可以考虑使用 Component.onCompleted 来一次性赋值,从而解除绑定,减少运行时的监听开销(尽管在此处影响微乎其微)。
    • 示例
      Component.onCompleted: {
          font = Qt.binding(function() { return menuItem.font });
          // 或者直接赋值(如果确定不变):
          // font = menuItem.font;
      }
    • :对于菜单项这种轻量级组件,当前写法通常是可以接受的,除非在低端设备上渲染成百上千个列表项时出现性能瓶颈。

4. 代码安全

  • 空值风险
    • 代码假设 DTK.fontManagerDTK.fontManager.t6 始终存在且有效。如果 DTK 模块加载失败或版本不兼容,可能会导致属性绑定错误或运行时异常。
    • 建议:确保在引入此代码前,项目已正确依赖并加载了 DTK 模块。

总结与改进建议

这段代码修改本身是正确且规范的,主要是为了适配 DDE 的设计规范。为了进一步提升代码质量,建议考虑以下改进:

  1. 统一风格库:确认 DStyleDTK 的使用边界。如果 DStyle 提供了字体定义,优先使用 DStyle 以保持依赖的单一性。
  2. 性能微调(可选):如果该菜单项在非常高频的刷新场景下,且字体属性是静态的,可以优化绑定方式。
  3. 代码注释:建议添加注释说明为何使用 t6 字体(例如:符合 DDE 设计规范中的菜单项标准),方便后续维护人员理解设计意图。

改进后的代码片段示例(仅供参考):

MenuItem {
    id: menuItem
    text: getCategoryName(modelData)
    textColor: DStyle.Style.menu.itemText
    // 使用 DTK 统一字体管理
    font: DTK.fontManager.t6 

    onTriggered: {
        scrollToDDECategory(modelData)
    }

    // 假设这是 contentItem 中的 Label
    Label {
        alignment: Qt.AlignCenter
        text: menuItem.text
        color: parent.palette.windowText
        // 继承字体设置
        font: menuItem.font 
    }
    // ...
}

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, electricface

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@electricface
Copy link
Member Author

/forcemerge

@deepin-bot deepin-bot bot merged commit ed1f249 into linuxdeepin:master Mar 9, 2026
11 checks passed
@electricface electricface deleted the swt/fix-bug335169 branch March 9, 2026 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants